<template>
  <view>
    <view class="w100 pl-60 pr-60">
      <view class="w100 h-124 rows rowsm" style="border-bottom: 1rpx solid rgba(0, 0, 0, .06);">
        <input type="text" password placeholder="请输入旧密码" placeholder-class="fs-30 col888" v-model="pwd">
      </view>
      <view class="w100 h-124 rows rowsm" style="border-bottom: 1rpx solid rgba(0, 0, 0, .06);">
        <input type="text" password placeholder="请输入新密码" placeholder-class="fs-30 col888" v-model="newPwd">
      </view>
      <view class="w100 h-124 rows rowsm" style="border-bottom: 1rpx solid rgba(0, 0, 0, .06);">
        <input type="text" password placeholder="确认密码" placeholder-class="fs-30 col888" v-model="newPwd2">
      </view>
      
      <view class="w100 mt-192 rowsc rowsm">
        <view class="w100 h-100 br-24 rowsc rowsm colfff fs-32 fw-b" style="background: linear-gradient(to bottom,#4897FF,#4878FF);" @click="changePwd()">确定</view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        pwd:'',
        newPwd:'',
        newPwd2:''
      };
    },
    methods:{
      changePwd(){
		  if(!this.pwd) return this.$tools.showtt('请输入密码')
		  if(!this.newPwd) return this.$tools.showtt('请输入新密码')
       // 密码长度在5-20位之间
      if(this.newPwd.length < 5 || this.newPwd.length > 20) return this.$tools.showtt('密码长度在5-20位之间')
      if(this.newPwd2.length < 5 || this.newPwd2.length > 20) return this.$tools.showtt('密码长度在5-20位之间')
		  if(this.newPwd != this.newPwd2) return this.$tools.showtt('两次密码不一致')
        let data = {
          password:this.pwd,
		  passwordNew:this.newPwd
        }
        this.$tools.axiosFromToken('POST','prouser/updatePassword',{...data},'加载中').then(res => {
		  this.$tools.showtt(res.msg)
		  if(res.code != 200) return
		  setTimeout(() => {
		  	this.$tools.goBack(1)
		  },1000)
        })
      }
    }
  }
</script>

<style lang="scss">
page {
  background-color: #fff;
}
</style>
